from django.urls import path
from .views.login import admin_jwt_token
from .views.home import DailyActiveAPIView, OrderCountAPIView, MonthCountAPIView, UserCountAPIView, UserDayCountAPIView
from .views.user import UserListView
from .views.image import SKUView
from .views.sku import SKUListModelViewSet, ThreeCategoryListAPIView, SPUListAPIView, SPUSpecificationView
from .views.order import OrderInfoView, OrderDetailView, OrderStatusView
from .views.spu import SPUListModelViewSet, BrandView, FirstGategoryView, SeThGategoryView
from .views.spec import SpecModelViewSet
from .views.option import SpecificationOptionModelViewSet,SpecListAPIView
from .views.brand import BrandModelViewSet
from .views.permission import PermissionModelViewSet,ContentTypeListAPIView
from .views.group import GroupModelViewSet,PermissionListAPIView
from .views.admin import AdminModelViewSet,GroupListAPIView


urlpatterns = [
    # URL路由可启用通过POST获得令牌的功能，其中包括用户的用户名和密码。
    # path('authorizations/', obtain_jwt_token),
    # 登录
    path('authorizations/', admin_jwt_token),
    path('statistical/day_active/', DailyActiveAPIView.as_view()),
    path('statistical/day_orders/', OrderCountAPIView.as_view()),
    path('statistical/month_increment/', MonthCountAPIView.as_view()),
    path('statistical/total_count/', UserCountAPIView.as_view()),
    path('statistical/day_increment/', UserDayCountAPIView.as_view()),
    # 用户管理
    path('users/', UserListView.as_view()),
    # 获取sku的所有id
    path('skus/simple/', SKUView.as_view()),
    # 获取三级分类信息
    path('skus/categories/', ThreeCategoryListAPIView.as_view()),
    # 获取spu表name数据
    path('goods/simple/', SPUListAPIView.as_view()),
    # 获取SPU商品规格信息
    path('goods/<int:spu_id>/specs/', SPUSpecificationView.as_view()),
    # 获取订单表数据
    path('orders/', OrderInfoView.as_view()),
    # 获取订单表详情数据
    path('orders/<int:order_id>/', OrderDetailView.as_view()),
    # 更新订单表状态
    path('orders/<int:order_id>/status/', OrderStatusView.as_view()),
    # 获取品牌信息
    path('goods/brands/simple/', BrandView.as_view()),
    # spu新增获取一级分类
    path('goods/channel/categories/', FirstGategoryView.as_view()),
    # 二三级分类
    path('goods/channel/categories/<int:pk>/', SeThGategoryView.as_view()),

    path('goods/specs/simple/', SpecListAPIView.as_view()),

    path('permission/content_types/', ContentTypeListAPIView.as_view()),

    path('permission/simple/', PermissionListAPIView.as_view()),

    path('permission/groups/simple/', GroupListAPIView.as_view()),

]

from rest_framework.routers import DefaultRouter
from .views.image import ImageView

router = DefaultRouter()
router.register(r'skus/images', ImageView, basename='skus_images')
# 所有的sku
router.register(r'skus', SKUListModelViewSet, basename='skus')
# 获取所有规格表数据
router.register(r'goods/specs', SpecModelViewSet, basename='spuspecs')
# 品牌管理
router.register(r'goods/brands', BrandModelViewSet, basename='brands')
# 获取所有规格选项表
router.register(r'specs/options', SpecificationOptionModelViewSet, basename='options')
# 获取所有SPU表数据
router.register(r'goods', SPUListModelViewSet, basename='goods')
# 权限管理
router.register(r'permission/perms', PermissionModelViewSet, basename='perms')
# 用户组管理
router.register(r'permission/groups', GroupModelViewSet, basename='groups')
# 管理员信息管理
router.register(r'permission/admins', AdminModelViewSet, basename='admins')

urlpatterns += router.urls



